﻿@model DishDelivery
@{
    ViewBag.Titlm = "送货单维护";
    Layout = "~/Views/Shared/_LayoutFormDetail.cshtml"; 
}
@section Up{
    @Html.HiddenFor(model => model.Id)
    @Html.HiddenFor(model => model.State)
    @Html.nbDropDownListFor(model => model.SiteID, "ProjectSite").Required()
    @Html.nbDateFor(model => model.Date).Required()
    @Html.nbTextBoxFor(model => model.Deliver).Required()
    @Html.nbTextBoxFor(model => model.DeliverDriver).Required()
    @Html.nbTextBoxFor(model => model.SignPerson).Required()
}
@section Down{
    @(Html.nbFormListFor<DishDeliveryItem>(s =>
    {
        s.ID("detail");
        s.Action(@Url.Action("EditList"));
        s.ExtParam(new { ParentId = "$('#Id').val()", siteId = @ViewBag.SiteId ?? "", date = @ViewBag.Date ?? "" });
        s.layoutW(10);
        s.layoutH(195);
        s.Columns(c =>
        {
            c.Bind(m => m.Id).IsKey();
            c.Bind(m => m.Code).Width(60);
            c.Bind(m => m.Name).Width(60).Align(GridAlign.Left);
            c.BindEnum(m => m.Category, "MaterialCategory").Width(60);
            c.Bind(m => m.DishName).Width(60).Align(GridAlign.Left);
            c.BindEnum(m => m.DishCategory, "DishType").Title("菜肴类别").Width(60);
            c.Bind(m => m.OrderCount).Width(50).Align(GridAlign.Right);
            c.BindControl(m => m.DeliveryCount).Width(45).Align(GridAlign.Right);
            c.BindControl(m => m.Price).Width(40).Align(GridAlign.Right);
            c.BindTemplate(45).Template(Url.GridRowClientDeleteLink());
        });
        s.Buttons(b =>
        {
            b.Bind("Add", "选择品名", GridButtonType.Add).OnClick("SelectMaterial");
        });
    }))
}
<script type="text/javascript">
    function SelectMaterial(e) {
        OpenModalDialog('@Url.Action("LookUp")',
        {
            width: 800,
            height: 500,
            type: 2,
            onclose:
            function (MaterialData) {
                if (MaterialData) {
                    $("#detail").flexAddRows(MaterialData);
                }
            }
        });
    }
</script>
